<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
  <head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	<meta name="keywords" content="zm">
	<meta name="description" content="zm后台管理">
    <title>任务调度</title>
	<link rel="stylesheet" href="common/layui/css/layui.css">
	<link rel="stylesheet" href="common/css/zm.css">
  </head>
<body>
	<div style="text-align: center;margin-top: 30px;">
		<form class="" id="myForm">
		<input type="hidden" name="jobId" id="jobId">
		  <div class="layui-form-item">
		    <label class="layui-form-label">任务名称:</label>
		    <div class="layui-input-inline">
		      <input type="text" name="jobName" id="jobName" required  lay-verify="required" placeholder="请输入任务名称" autocomplete="off" class="layui-input">
		    </div>
		    <label class="layui-form-label">任务组名:</label> 
		    <div class="layui-input-inline">
		      <input type="text" name="jobGroup" id="jobGroup" required lay-verify="required" placeholder="请输入任务组名" autocomplete="off" class="layui-input">
		    </div>
		    <label class="layui-form-label">执行类:</label>
		    <div class="layui-input-inline">
		      <input type="text" name="className" id="className" required lay-verify="required" placeholder="请输入执行类" autocomplete="off" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">ip:</label>
		    <div class="layui-input-inline">
		      <input type="text" name="ip" id="ip"  placeholder="请输入ip" autocomplete="off" class="layui-input">
		    </div>
		    <label class="layui-form-label">cron：</label>
		    <div class="layui-input-inline">
		      <input type="text" name="cronExpression" id="cronExpression" required lay-verify="required" placeholder="请输入cron表达式" autocomplete="off" class="layui-input">
		    </div>
		  </div>
		 
		  <div class="layui-form-item layui-form-text">
		    <label class="layui-form-label">任务描述</label>
		    <div class="layui-input-block">
		      <textarea name="jobDesc" id="jobDesc" placeholder="请输入内容" class="layui-textarea" style="width:80%"></textarea>
		    </div>
		  </div>
		  <div class="layui-form-item layui-form-text" style="text-align: left;margin-left: 50px;">
		  	<p>Cron表达式范例：</p>
			<p>每隔5秒执行一次：*/5 * * * * ?</p>
            <p> 每隔1分钟执行一次：0 */1 * * * ?</p>
            <p>每天23点执行一次：0 0 23 * * ?</p>
            <p>每天凌晨1点执行一次：0 0 1 * * ?</p>
            <p> 每月1号凌晨1点执行一次：0 0 1 1 * ?</p>
            <p>每月最后一天23点执行一次：0 0 23 L * ?</p>
            <p>每周星期天凌晨1点实行一次：0 0 1 ? * L</p>
            <p>在26分、29分、33分执行一次：0 26,29,33 * * * ?</p>
            <p>每天的0点、13点、18点、21点都执行一次：0 0 0,13,18,21 * * ?</p>
		  </div>
		</form>
		<div class="layui-input-block">
	      	<button class="layui-btn" onclick="saveJob()">保存</button>
	      	<button type="reset" class="layui-btn layui-btn-primary" onclick="history.back();">返回</button>
	     </div>
	</div>
	<script type="text/javascript" src="common/js/jquery-3.1.0.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			if("${param.id}"!=null&&"${param.id}"!=""){
				$.ajax({
	        		url:'schedule/getSchedule',
	        		data:{'id':"${param.id}"},
	        		type:'post',
	        		dataType:'json',
	        		success:function(result){
	        			if(result.status=='200'){
	        				var data=result.data;
	        				$("#jobId").val(data.jobId);
	        				$("#jobName").val(data.jobName);
	        				$("#jobGroup").val(data.jobGroup);
	        				$("#className").val(data.className);
	        				$("#ip").val(data.ip);
	        				$("#cronExpression").val(data.cronExpression);
	        				$("#jobDesc").val(data.jobDesc);
	        			}else{
	        				alert(result.msg);
	        			}
	        		},
	        		error:function(result){
	        			alert(result.msg);
	        		}
	        	});
			}
		});
	
	
	
		function saveJob(){
			$.ajax({
        		url:'schedule/save',
        		data:$('#myForm').serialize(),
        		type:'post',
        		dataType:'json',
        		success:function(result){
        			if(result.status=='200'){
        				window.location.href="jsp/manager/schedule/list.jsp";
        			}else{
        				alert(result.msg);
        			}
        		},
        		error:function(result){
        			alert(result.msg);
        		}
        		
        	});
		}
	</script>
</body>
</html>